home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / emu-mess.swf / scripts / frame_3 / PlaceObject2_460_1116 / CLIPACTIONRECORD onClipEvent(enterFrame).as
Encoding:
Text File  |  2008-08-08  |  10.4 KB  |  286 lines

  1. onClipEvent(enterFrame){
  2.    for(myItem in _root.activeItems)
  3.    {
  4.       _root.fall(myItem);
  5.    }
  6.    for(myItem in _root.activeFoams)
  7.    {
  8.       _root.fallFoam(myItem);
  9.    }
  10.    if(!_root.gameFinished && !_root.emu.inLift)
  11.    {
  12.       if(_root.sophie.pausedState != 0)
  13.       {
  14.          _root.sophieClip.gotoAndStop(_root.sophie.pausedState);
  15.          _root.sophie.pausedState = 0;
  16.       }
  17.       if(getTimer() > _root.gameTimer)
  18.       {
  19.          _root.sophie.homing = 2.5 * Math.ceil((getTimer() - _root.gameTimer) / 15000);
  20.       }
  21.       _root.sophieHeartBeat();
  22.       if(!_root.emu.elevator)
  23.       {
  24.          if(!_root.emu.landing && !_root.emu.falling && !_root.emu.onLadder)
  25.          {
  26.             if(_root.emu._x > _root["holeArray" + _root.emu.myFloor][0].xMin && _root.emu._x < _root["holeArray" + _root.emu.myFloor][0].xMax && _root["floor" + _root.emu.myFloor] - _root.emu._y - _root.emu.emuHeight > -1 && _root["floor" + _root.emu.myFloor] - _root.emu._y - _root.emu.emuHeight < 20)
  27.             {
  28.                _root.emu.gotoAndStop("fall" + (_root.emu.xdir + 1));
  29.                _root.emu.falling = 1;
  30.                _root.emu.myFloor = _root.emu.myFloor + 1;
  31.             }
  32.          }
  33.          if(_root.emu._y != _root["floor" + _root.emu.myFloor] - _root.emu.emuHeight && !_root.emu.onLadder)
  34.          {
  35.             if(_root.emu.yspeed + 2 < _root.emu.terminal)
  36.             {
  37.                _root.emu.yspeed += 2;
  38.             }
  39.             if(_root.emu._x > _root["holeArray" + _root.emu.myFloor][0].xMin && _root.emu._x < _root["holeArray" + _root.emu.myFloor][0].xMax && _root.emu.myFloor < 4 && _root["floor" + _root.emu.myFloor] - _root.emu._y - _root.emu.emuHeight > -1 && _root["floor" + _root.emu.myFloor] - _root.emu._y - _root.emu.emuHeight < 20)
  40.             {
  41.                _root.emu.myFloor = _root.emu.myFloor + 1;
  42.                _root.emu._y += _root.emu.yspeed;
  43.             }
  44.             else if(!_root.emu.landing && _root.emu._y + _root.emu.yspeed > _root["floor" + _root.emu.myFloor] - _root.emu.emuHeight)
  45.             {
  46.                _root.emu._y = _root["floor" + _root.emu.myFloor] - _root.emu.emuHeight;
  47.                _root.emu.gotoAndStop("land" + (_root.emu.xdir + 1));
  48.                _root.emu.yspeed = 0;
  49.                _root.emu.landing = 1;
  50.             }
  51.             else
  52.             {
  53.                _root.emu._y += _root.emu.yspeed;
  54.             }
  55.          }
  56.          _root.emu.emuBraking = 0.8;
  57.          if(!_root.emu.landing && Key.isDown(40) && !_root.emu.onLadder)
  58.          {
  59.             if(_root.ladders.hitTest(_root.emu._x,_root.emu._y + _root.emu.emuHeight,true))
  60.             {
  61.                if(!_root.emu.onLadder)
  62.                {
  63.                   _root.emu.onLadder = 1;
  64.                   _root.emu.myFloor = _root.emu.myFloor + 1;
  65.                   _root.emu.speed = 0;
  66.                }
  67.                _root.emu.ladderDir = 1;
  68.                _root.emu._y += 5;
  69.                _root.emu.gotoAndStop("climb");
  70.             }
  71.             else
  72.             {
  73.                _root.emu.onLadder = 0;
  74.             }
  75.          }
  76.          else if(!_root.emu.landing && Key.isDown(38) && !_root.emu.onLadder)
  77.          {
  78.             if(_root.ladders.hitTest(_root.emu._x,_root.emu._y,true))
  79.             {
  80.                if(!_root.emu.onLadder)
  81.                {
  82.                   _root.emu.onLadder = 1;
  83.                   _root.emu.myFloor--;
  84.                   _root.emu.speed = 0;
  85.                }
  86.                _root.emu.ladderDir = -1;
  87.                _root.emu._y -= 5;
  88.                _root.emu.gotoAndStop("climb");
  89.             }
  90.             else
  91.             {
  92.                _root.emu.onLadder = 0;
  93.             }
  94.          }
  95.          else if(!_root.emu.landing && _root.emu.onLadder)
  96.          {
  97.             if(_root.emu.ladderDir == -1 && !_root.ladders.hitTest(_root.emu._x,_root.emu._y,true))
  98.             {
  99.                _root.emu.onLadder = 0;
  100.             }
  101.             else if(_root.emu.ladderDir == 1 && !_root.ladders.hitTest(_root.emu._x,_root.emu._y + _root.emu.emuHeight,true))
  102.             {
  103.                _root.emu.onLadder = 0;
  104.             }
  105.             else
  106.             {
  107.                _root.emu._y += _root.emu.ladderDir * 5;
  108.             }
  109.          }
  110.          if(!_root.emu.landing && Key.isDown(37) && !_root.emu.onLadder)
  111.          {
  112.             if(_root.emu.xdir == 1 && _root.emu.speed > 0)
  113.             {
  114.                _root.emu.speed -= _root.emu.emuBraking;
  115.             }
  116.             else
  117.             {
  118.                _root.emu.xdir = -1;
  119.                if(_root.emu.speed < 10)
  120.                {
  121.                   _root.emu.speed = _root.emu.speed + 1;
  122.                }
  123.             }
  124.             if(!_root.emu.falling && !_root.emu.landing && !_root.emu.peck && _root.emu._currentframe != 4)
  125.             {
  126.                _root.emu.gotoAndStop("run" + (_root.emu.xdir + 1));
  127.             }
  128.          }
  129.          else if(!_root.emu.landing && Key.isDown(39) && !_root.emu.onLadder)
  130.          {
  131.             if(_root.emu.xdir == -1 && _root.emu.speed > 0)
  132.             {
  133.                _root.emu.speed -= _root.emu.emuBraking;
  134.             }
  135.             else
  136.             {
  137.                _root.emu.xdir = 1;
  138.                if(_root.emu.speed < 10)
  139.                {
  140.                   _root.emu.speed = _root.emu.speed + 1;
  141.                }
  142.             }
  143.             if(!_root.emu.falling && !_root.emu.landing && !_root.emu.peck && _root.emu._currentframe != 3)
  144.             {
  145.                _root.emu.gotoAndStop("run" + (_root.emu.xdir + 1));
  146.             }
  147.          }
  148.          else if(_root.emu.speed > 0)
  149.          {
  150.             _root.emu.speed -= _root.emu.emuBraking;
  151.             if(!_root.emu.falling && !_root.emu.landing && !_root.emu.peck)
  152.             {
  153.                _root.emu.gotoAndStop("skid" + (_root.emu.xdir + 1));
  154.             }
  155.          }
  156.          else if(!_root.emu.onLadder && !_root.emu.falling && !_root.emu.landing && !_root.emu.peck)
  157.          {
  158.             _root.emu.gotoAndStop("static" + (_root.emu.xdir + 1));
  159.          }
  160.          if(_root.emu.speed > 0)
  161.          {
  162.             if(_root.emu.xdir == -1)
  163.             {
  164.                if(_root.emu._x > 0)
  165.                {
  166.                   _root.emu._x -= _root.emu.speed;
  167.                }
  168.             }
  169.             else if(_root.emu._x < Stage.width)
  170.             {
  171.                _root.emu._x += _root.emu.speed;
  172.             }
  173.          }
  174.          triggerPeck = 0;
  175.          if(!_root.emu.landing && Key.isDown(32) && _root.peckReleased)
  176.          {
  177.             if(!_root.emu.peck)
  178.             {
  179.                _root.emu.peckPointer = _root.emu.peckPointer + 1;
  180.                if(_root.emu.peckPointer > 3)
  181.                {
  182.                   _root.emu.peckPointer = 1;
  183.                }
  184.                _root.peckReleased = 0;
  185.                peckHeight = _root["peckHeight" + _root.emu.peckPointer];
  186.                _root.emu.peck = 1;
  187.                triggerPeck = 1;
  188.             }
  189.          }
  190.          else if(!Key.isDown(32))
  191.          {
  192.             _root.peckReleased = 1;
  193.          }
  194.          if(triggerPeck)
  195.          {
  196.             if(peckHeight == _root.peckHeight1)
  197.             {
  198.                _root.emu.gotoAndStop("peckLow" + (_root.emu.xdir + 1));
  199.             }
  200.             else if(peckHeight == _root.peckHeight2)
  201.             {
  202.                _root.emu.gotoAndStop("peckMid" + (_root.emu.xdir + 1));
  203.             }
  204.             else if(peckHeight == _root.peckHeight3)
  205.             {
  206.                _root.emu.gotoAndStop("peckHigh" + (_root.emu.xdir + 1));
  207.             }
  208.             if(Math.abs(_root.emu._x + _root.emu.xdir * (_root.emu._width / 2) - _root.sophieClip._x) < 25 && _root.emu.myFloor == _root.sophie.myFloor)
  209.             {
  210.                _root.turnToWalkOff();
  211.                _root.emu.gotoAndStop("peckMid" + (_root.emu.xdir + 1));
  212.                _root.sophie.behaviour = "pecked";
  213.                _root.sophie.pecked = 1;
  214.                _root.sophieClip.gotoAndStop("pecked");
  215.             }
  216.             if(_root.emu.speed <= 0)
  217.             {
  218.                _root.emu.legs.gotoAndStop("static" + (_root.emu.xdir + 1));
  219.             }
  220.             else
  221.             {
  222.                _root.emu.legs.gotoAndStop("run" + (_root.emu.xdir + 1));
  223.             }
  224.             _root.emu.elevator = 0;
  225.             if(_root.emu._y < _root.floor1)
  226.             {
  227.                peckFloor = 1;
  228.             }
  229.             else if(_root.emu._y < _root.floor2)
  230.             {
  231.                peckFloor = 2;
  232.                if(Math.abs(_root.emu._x + _root.emu.xdir * (_root.emu._width / 2) - _root.el1._x) < 15)
  233.                {
  234.                   _root.emu.elevator = 1;
  235.                   _root.emu.elevatorTo = 4;
  236.                   _root.emu.elevatorFrom = 2;
  237.                }
  238.             }
  239.             else if(_root.emu._y < _root.floor3)
  240.             {
  241.                peckFloor = 3;
  242.             }
  243.             else
  244.             {
  245.                peckFloor = 4;
  246.                if(Math.abs(_root.emu._x + _root.emu.xdir * (_root.emu._width / 2) - _root.el1._x) < 15)
  247.                {
  248.                   _root.emu.elevator = 1;
  249.                   _root.emu.elevatorTo = 2;
  250.                   _root.emu.elevatorFrom = 4;
  251.                }
  252.             }
  253.             if(!_root.emu.elevator)
  254.             {
  255.                peckSquare = Math.floor((_root.emu._x + _root.emu.xdir * (_root.emu._width / 2)) / 50) + 1;
  256.                _root.peckDetector(peckHeight,peckFloor,peckSquare);
  257.             }
  258.             else
  259.             {
  260.                _root.emu.peck = 0;
  261.                _root.emu._x = 150;
  262.                _root["elDoor" + _root.emu.elevatorFrom].doors.gotoAndPlay("enterLift");
  263.                _root.sophie.pausedState = _root.sophieClip._currentframe;
  264.                _root.theme.stop();
  265.                _root.themePoint = Math.round(_root.theme.position / 1000);
  266.                _root.elevatorDing.start(0,1);
  267.                _root.elevatorMusic.start(0,1);
  268.                _root.emu._visible = 0;
  269.                _root.emu._y = _root["floor" + _root.emu.elevatorTo] - _root.emu.emuHeight;
  270.                _root.emu.myFloor = _root.emu.elevatorTo;
  271.                _root.emu.inLift = 1;
  272.             }
  273.          }
  274.       }
  275.    }
  276.    else if(_root.emu.inLift)
  277.    {
  278.       _root.sophieClip.gotoAndStop("static");
  279.    }
  280.    else if(_root.gameFinished)
  281.    {
  282.       _root.sophieClip.gotoAndStop(_root.sophieState);
  283.       _root.emu.gotoAndStop(_root.emuState);
  284.    }
  285. }
  286.